package com.liguangting.agentsflex.simple;

import com.agentsflex.core.llm.Llm;
import com.agentsflex.core.llm.response.FunctionMessageResponse;
import com.agentsflex.core.prompt.FunctionPrompt;
import com.agentsflex.llm.openai.OpenAiLlm;
import com.agentsflex.llm.qwen.QwenLlm;
import com.agentsflex.llm.qwen.QwenLlmConfig;
import com.agentsflex.llm.spark.SparkLlm;
import com.agentsflex.llm.spark.SparkLlmConfig;
import com.liguangting.agentsflex.constant.ApiKeys;
import com.liguangting.agentsflex.tool.TestTools;
import com.liguangting.agentsflex.tool.WeatherUtil;


/**
 * @author liguangting
 * @date 2024/7/4
 * @description
 */
public class FunctionCallTest {

    public static void main(String[] args) {
//        QwenLlmConfig config = new QwenLlmConfig();
//        config.setApiKey(ApiKeys.QWEN_API_KEY);
//        Llm llm = new QwenLlm(config);

//        Llm llm = OpenAiLlm.of(ApiKeys.OPENAI_API_KEY);

        SparkLlmConfig config = new SparkLlmConfig();
        config.setAppId(ApiKeys.SPARK_APP_ID);
        config.setApiKey(ApiKeys.SPARK_API_KEY);
        config.setApiSecret(ApiKeys.SPARK_API_SECRET);
        config.setVersion("v3.5");
        Llm llm = new SparkLlm(config);

//        FunctionPrompt prompt = new FunctionPrompt("今天北京的天气怎么样", WeatherUtil.class);
        FunctionPrompt prompt = new FunctionPrompt("What is 1+2 , What is 3*4 , what's 1's name, what's 1000's name?", TestTools.class);
        FunctionMessageResponse response = llm.chat(prompt);

        //执行工具类方法得到结果
        Object result = response.getFunctionResult();

        System.out.println(result);
    }
}

